/* eslint react-hooks/exhaustive-deps:"off" */
import React, { useEffect } from 'react'

/**
 * 组件首次渲染后，启动一个计时器
 * 卸载后清除
 * @param {*} fn 
 * @param {*} duration 
 * @returns 
 */
export default function useTimer(fn, duration) {

    useEffect(() => {
        const timer = setInterval(fn, duration)

        return () => {
            clearInterval(timer)
        }
    }, [])


    return (
        <div>useTimer</div>
    )
}
